set seed 10000
cap cd ""

use GSDB.dta, clear

cmp setup

*Model 1 of Talbe 1
cmp (targetcompliance = thirdpartyrival costlysanctions ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(sanction = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel t_sanc-t_sanc3), ///
ind(sanction*$cmp_probit $cmp_probit) robust  

*Model 2 of Talbe 1
cmp (targetcompliance = thirdpartyrival costlysanctions thirdpartyrival_cost  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(sanction = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel t_sanc-t_sanc3), ///
ind(sanction*$cmp_probit $cmp_probit) robust  

*Model 3 of Talbe 1
cmp (modestgoalcompliance = thirdpartyrival costlysanctions thirdpartyrival_cost  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(modestgoalsanctions = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel mi_sanc mi_sanc2 mi_sanc3), ///
ind(modestgoalsanctions*$cmp_probit $cmp_probit) robust  

*Left Panel of Figure 1
preserve

drawnorm b1-b27, n(10000) means(e(b)) cov(e(V)) clear
	  
cap postclose simulation
postfile simulation triv pr_y1 pr_y2 diff diff_l diff_h using "simulation", replace

foreach n of numlist 0(1)10 {
		
	cap drop y1 y2 diff* pr*

		scalar riv = `n'
		scalar pol_riv = 0
		scalar riv_comp = 0
		scalar comp = 0
		scalar inst = 0
		scalar tdem = -0.75
		scalar trddep =  .019
		scalar biriv = 0
		scalar gdppc = 8.071
		scalar tcinc = -6.03
		scalar post = 1
		scalar dur = 5.96
		scalar cons = 1

		generate y1 = b1*riv ///
					+ b2*comp ///
					+ b3*riv_comp ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y1 = normprob(y1)
		sum pr_y1
		local pr_y1 =r(mean)
		

		generate y2 = b1*riv ///
					+ b2*(comp + 1) ///
					+ b3*(riv_comp + `n') ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y2 = normprob(y2)
		sum pr_y2
		local pr_y2 =r(mean)
		
		gen diff = pr_y2 - pr_y1
		sum diff 
		local diff =r(mean)
		
		_pctile diff, p(2.5,97.5)
		local diff_l= r(r1)
		local diff_h= r(r2)  
		
	
post simulation (`n') (`pr_y1') (`pr_y2') (`diff') (`diff_l') (`diff_h') 
	}
postclose simulation

use simulation, clear

gen hist = .
replace hist = 44.06 if triv == 0
replace hist = 24.24 if triv == 1
replace hist = 10.02 if triv == 2
replace hist = 6.53 if triv == 3
replace hist = 4.20 if triv == 4
replace hist = 6.06 if triv == 5
replace hist = 1.63 if triv == 6
replace hist = 2.33 if triv == 7
replace hist = 0.70 if triv == 8
replace hist = 0 if triv == 9
replace hist = 0.23 if triv == 10

twoway (line diff triv, lpattern(solid) yaxis(1)) (line diff_l triv, lpattern(dash) yaxis(1)) (line diff_h triv, lpattern(dash) yaxis(1)) ///
(bar hist triv, yaxis(2) barw(.2) color(%30) ytitle("Percent", axis(2)) ylabel(0(10)40, axis(2))), ///
yline(0,lpattern(dash)) ylabel(-.8(.2).4) ytitle("Change of pr(Target Compliance)", size(medsmall)) xtitle("Third-Party Rivals", size(medsmall)) ///
legend(off) title("Effect of Costly Sanctions (Modest Policy Goals)", size(medsmall)) name(g1, replace) 

restore

*Model 4 of Talbe 1
cmp (majorgoalcompliance= thirdpartyrival costlysanctions thirdpartyrival_cost  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(majorgoalsanctions = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel mi_sanc mi_sanc2 mi_sanc3), ///
ind(majorgoalsanctions*$cmp_probit $cmp_probit) robust  

*Right Panel of Figure 1
preserve

drawnorm b1-b27, n(10000) means(e(b)) cov(e(V)) clear
	  
cap postclose simulation
postfile simulation triv pr_y1 pr_y2 diff diff_l diff_h using "simulation", replace

foreach n of numlist 0(1)10 {
		
	cap drop y1 y2 diff* pr*

		scalar riv = `n'
		scalar riv_comp = 0
		scalar inst = 0
		scalar tdem = -1.157
		scalar trddep =  .016
		scalar biriv = 0
		scalar gdppc = 7.666
		scalar tcinc = -6.271
		scalar post = 1
		scalar comp = 0
		scalar dur = 6.7
		scalar cons = 1

		generate y1 = b1*riv ///
					+ b2*comp ///
					+ b3*riv_comp ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y1 = normprob(y1)
		sum pr_y1
		local pr_y1 =r(mean)
		

		generate y2 = b1*riv ///
					+ b2*(comp + 1) ///
					+ b3*(riv_comp + `n') ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y2 = normprob(y2)
		sum pr_y2
		local pr_y2 =r(mean)
		
		gen diff = pr_y2 - pr_y1
		sum diff 
		local diff =r(mean)
		
		_pctile diff, p(2.5,97.5)
		local diff_l= r(r1)
		local diff_h= r(r2)  
		
	
post simulation (`n') (`pr_y1') (`pr_y2') (`diff') (`diff_l') (`diff_h') 
	}
postclose simulation

use simulation, clear

gen hist = .
replace hist = 35.41 if triv == 0
replace hist = 22.45 if triv == 1
replace hist = 12.95 if triv == 2
replace hist = 10.88 if triv == 3
replace hist = 3.11 if triv == 4
replace hist = 6.91 if triv == 5
replace hist = 3.11 if triv == 6
replace hist = 1.04 if triv == 7
replace hist = 2.59 if triv == 8
replace hist = 1.38 if triv == 9
replace hist = 0.17 if triv == 10

twoway (line diff triv, lpattern(solid) yaxis(1)) (line diff_l triv, lpattern(dash) yaxis(1)) (line diff_h triv, lpattern(dash) yaxis(1)) ///
(bar hist triv, yaxis(2) barw(.2) color(%30) ytitle("Percent", axis(2)) ylabel(0(10)40, axis(2))), ///
yline(0,lpattern(dash)) ylabel(-.8(.2).4) ytitle("Change of pr(Target Compliance)", size(medsmall)) xtitle("Third-Party Rivals", size(medsmall)) ///
legend(off) title("Effect of Costly Sanctions (Major Policy Goals)", size(medsmall)) name(g1, replace) 

restore
********************************************************************************
*Model 1 of Table A4
cmp (modestgoalcompliance_pc = thirdpartyrival costlysanctions thirdpartyrival_cost  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(modestgoalsanctions_policychange = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel mi_sanc_pc2*), ///
ind(modestgoalsanctions_policychange*$cmp_probit $cmp_probit) robust  

*Top Panel of Figure A2
preserve

drawnorm b1-b27, n(10000) means(e(b)) cov(e(V)) clear
	  
cap postclose simulation
postfile simulation triv pr_y1 pr_y2 diff diff_l diff_h using "simulation", replace

foreach n of numlist 0(1)8 {
		
	cap drop y1 y2 diff* pr*

		scalar riv = `n'
		scalar pol_riv = 0
		scalar riv_comp = 0
		scalar comp = 0
		scalar inst = 0
		scalar tdem = -1.75
		scalar trddep = .02
		scalar biriv = 0
		scalar gdppc = 7.91
		scalar tcinc = -6.23
		scalar post = 1
		scalar dur = 5.87
		scalar cons = 1

		generate y1 = b1*riv ///
					+ b2*comp ///
					+ b3*riv_comp ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y1 = normprob(y1)
		sum pr_y1
		local pr_y1 =r(mean)
		

		generate y2 = b1*riv ///
					+ b2*(comp + 1) ///
					+ b3*(riv_comp + `n') ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y2 = normprob(y2)
		sum pr_y2
		local pr_y2 =r(mean)
		
		gen diff = pr_y2 - pr_y1
		sum diff 
		local diff =r(mean)
		
		_pctile diff, p(2.5,97.5)
		local diff_l= r(r1)
		local diff_h= r(r2)  
		
	
post simulation (`n') (`pr_y1') (`pr_y2') (`diff') (`diff_l') (`diff_h') 
	}
postclose simulation

use simulation, clear

gen hist = .
replace hist = 45.5 if triv == 0
replace hist = 27.1 if triv == 1
replace hist = 10.3 if triv == 2
replace hist = 6.5 if triv == 3
replace hist = 2.90 if triv == 4
replace hist = 2.9 if triv == 5
replace hist = 1.3 if triv == 6
replace hist = 2.6 if triv == 7
replace hist = 1 if triv == 8

twoway (line diff triv, lpattern(solid) yaxis(1)) (line diff_l triv, lpattern(dash) yaxis(1)) (line diff_h triv, lpattern(dash) yaxis(1)) ///
(bar hist triv, yaxis(2) barw(.2) color(%30) ytitle("Percent", axis(2)) ylabel(0(10)40, axis(2))), ///
yline(0,lpattern(dash)) ylabel(-.8(.2).4) ytitle("Change of pr(Target Compliance)", size(medsmall)) xtitle("Third-Party Rivals", size(medsmall)) ///
legend(off) title("Effect of Costly Sanctions (Modest Policy Goals)", size(medsmall)) name(g1, replace) 

restore

*Model 2 of Table A4
cmp (majorgoalcompliance_pc = thirdpartyrival costlysanctions thirdpartyrival_cost  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(majorgoalsanctions_policychange = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel si_sanc_pc2*), ///
ind(majorgoalsanctions_policychange*$cmp_probit $cmp_probit) robust  

*Model 3 of Table A4
cmp (modestgoalcompliance = thirdpartyrival costlysanctions thirdpartyrival_cost  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration hrsanc) ///
(modestgoalsanctions = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel mi_sanc mi_sanc2 mi_sanc3), ///
ind(modestgoalsanctions*$cmp_probit $cmp_probit) robust  

*Bottom Panel of Figure A2
preserve

drawnorm b1-b28, n(10000) means(e(b)) cov(e(V)) clear
	  
cap postclose simulation
postfile simulation triv pr_y1 pr_y2 diff diff_l diff_h using "simulation", replace

foreach n of numlist 0(1)10 {
		
	cap drop y1 y2 diff* pr*

		scalar riv = `n'
		scalar pol_riv = 0
		scalar riv_comp = 0
		scalar comp = 0
		scalar inst = 0
		scalar tdem = -0.75
		scalar trddep =  .019
		scalar biriv = 0
		scalar gdppc = 8.071
		scalar tcinc = -6.03
		scalar post = 1
		scalar dur = 5.96
		scalar hrsanc = 1
		scalar cons = 1

		generate y1 = b1*riv ///
					+ b2*comp ///
					+ b3*riv_comp ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*hrsanc ///
					+ b13*cons 
						
		gen pr_y1 = normprob(y1)
		sum pr_y1
		local pr_y1 =r(mean)
		

		generate y2 = b1*riv ///
					+ b2*(comp + 1) ///
					+ b3*(riv_comp + `n') ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*hrsanc ///
					+ b13*cons 
						
		gen pr_y2 = normprob(y2)
		sum pr_y2
		local pr_y2 =r(mean)
		
		gen diff = pr_y2 - pr_y1
		sum diff 
		local diff =r(mean)
		
		_pctile diff, p(2.5,97.5)
		local diff_l= r(r1)
		local diff_h= r(r2)  
		
	
post simulation (`n') (`pr_y1') (`pr_y2') (`diff') (`diff_l') (`diff_h') 
	}
postclose simulation

use simulation, clear

gen hist = .
replace hist = 44.06 if triv == 0
replace hist = 24.24 if triv == 1
replace hist = 10.02 if triv == 2
replace hist = 6.53 if triv == 3
replace hist = 4.20 if triv == 4
replace hist = 6.06 if triv == 5
replace hist = 1.63 if triv == 6
replace hist = 2.33 if triv == 7
replace hist = 0.70 if triv == 8
replace hist = 0 if triv == 9
replace hist = 0.23 if triv == 10

twoway (line diff triv, lpattern(solid) yaxis(1)) (line diff_l triv, lpattern(dash) yaxis(1)) (line diff_h triv, lpattern(dash) yaxis(1)) ///
(bar hist triv, yaxis(2) barw(.2) color(%30) ytitle("Percent", axis(2)) ylabel(0(10)40, axis(2))), ///
yline(0,lpattern(dash)) ylabel(-.8(.2).4) ytitle("Change of pr(Target Compliance)", size(medsmall)) xtitle("Third-Party Rivals", size(medsmall)) ///
legend(off) title("Effect of Costly Sanctions (Modest Policy Goals)", size(medsmall)) name(g1, replace) 

restore

*Model 1 of Table A5
cmp (modestgoalcompliance2 = thirdpartyrival costlysanctions thirdpartyrival_cost  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(modestgoalsanctions = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel mi_sanc mi_sanc2 mi_sanc3), ///
ind(modestgoalsanctions*$cmp_probit $cmp_probit) robust  

*Top Panel of Figure A4
preserve

drawnorm b1-b27, n(10000) means(e(b)) cov(e(V)) clear
	  
cap postclose simulation
postfile simulation triv pr_y1 pr_y2 diff diff_l diff_h using "simulation", replace

foreach n of numlist 0(1)10 {
		
	cap drop y1 y2 diff* pr*

		scalar riv = `n'
		scalar pol_riv = 0
		scalar riv_comp = 0
		scalar comp = 0
		scalar inst = 0
		scalar tdem = -0.75
		scalar trddep =  .019
		scalar biriv = 0
		scalar gdppc = 8.071
		scalar tcinc = -6.03
		scalar post = 1
		scalar dur = 5.96
		scalar cons = 1

		generate y1 = b1*riv ///
					+ b2*comp ///
					+ b3*riv_comp ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y1 = normprob(y1)
		sum pr_y1
		local pr_y1 =r(mean)
		

		generate y2 = b1*riv ///
					+ b2*(comp + 1) ///
					+ b3*(riv_comp + `n') ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y2 = normprob(y2)
		sum pr_y2
		local pr_y2 =r(mean)
		
		gen diff = pr_y2 - pr_y1
		sum diff 
		local diff =r(mean)
		
		_pctile diff, p(2.5,97.5)
		local diff_l= r(r1)
		local diff_h= r(r2)  
		
	
post simulation (`n') (`pr_y1') (`pr_y2') (`diff') (`diff_l') (`diff_h') 
	}
postclose simulation

use simulation, clear

gen hist = .
replace hist = 44.06 if triv == 0
replace hist = 24.24 if triv == 1
replace hist = 10.02 if triv == 2
replace hist = 6.53 if triv == 3
replace hist = 4.20 if triv == 4
replace hist = 6.06 if triv == 5
replace hist = 1.63 if triv == 6
replace hist = 2.33 if triv == 7
replace hist = 0.70 if triv == 8
replace hist = 0 if triv == 9
replace hist = 0.23 if triv == 10

twoway (line diff triv, lpattern(solid) yaxis(1)) (line diff_l triv, lpattern(dash) yaxis(1)) (line diff_h triv, lpattern(dash) yaxis(1)) ///
(bar hist triv, yaxis(2) barw(.2) color(%30) ytitle("Percent", axis(2)) ylabel(0(10)40, axis(2))), ///
yline(0,lpattern(dash)) ylabel(-.8(.2).4) ytitle("Change of pr(Target Compliance)", size(medsmall)) xtitle("Third-Party Rivals", size(medsmall)) ///
legend(off) title("Effect of Costly Sanctions (Modest Policy Goals))", size(medsmall)) name(g1, replace) 

restore

*Model 2 of Table A5
cmp (majorgoalcompliance2 = thirdpartyrival costlysanctions thirdpartyrival_cost  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(majorgoalsanctions = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel si_sanc si_sanc2 si_sanc3), ///
ind(majorgoalsanctions*$cmp_probit $cmp_probit) robust  

*Model 3 of Table A5
cmp (modestgoalcompliance= thirdpartyrival_cinc costlysanctions thirdrivalcinc_cost  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(modestgoalsanctions = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel mi_sanc mi_sanc2 mi_sanc3), ///
ind(modestgoalsanctions*$cmp_probit $cmp_probit) robust  

hist thirdpartyrival_cinc if e(sample), percent xtitle("Third-Party Rivals (Log CINC Score)") name(h1, replace) fysize(20)  ylabel(0(20)40)

*Bottom Panel of Figure A3
preserve

drawnorm b1-b27, n(10000) means(e(b)) cov(e(V)) clear
	  
cap postclose simulation
postfile simulation triv pr_y1 pr_y2 diff diff_l diff_h using "simulation", replace

foreach n of numlist -14(.5)-1.5 {
		
	cap drop y1 y2 diff* pr*

		scalar riv = `n'
		scalar pol_riv = 0
		scalar riv_comp = 0
		scalar comp = 0
		scalar inst = 0
		scalar tdem = -0.75
		scalar trddep =  .019
		scalar biriv = 0
		scalar gdppc = 8.071
		scalar tcinc = -6.03
		scalar post = 1
		scalar dur = 5.96
		scalar cons = 1

		generate y1 = b1*riv ///
					+ b2*comp ///
					+ b3*riv_comp ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y1 = normprob(y1)
		sum pr_y1
		local pr_y1 =r(mean)
		

		generate y2 = b1*riv ///
					+ b2*(comp + 1) ///
					+ b3*(riv_comp + `n') ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y2 = normprob(y2)
		sum pr_y2
		local pr_y2 =r(mean)
		
		gen diff = pr_y2 - pr_y1
		sum diff 
		local diff =r(mean)
		
		_pctile diff, p(2.5,97.5)
		local diff_l= r(r1)
		local diff_h= r(r2)  
		
	
post simulation (`n') (`pr_y1') (`pr_y2') (`diff') (`diff_l') (`diff_h') 
	}
postclose simulation

use simulation, clear

twoway (line diff triv, lpattern(solid) yaxis(1)) (line diff_l triv, lpattern(dash) yaxis(1)) (line diff_h triv, lpattern(dash) yaxis(1)), ///
yline(0,lpattern(dash)) ytitle("Change of pr(Target Compliance)", size(medsmall)) ///
legend(off) xtitle("") title("Effect of Costly Sanctions (Modest Policy Goals)", size(medsmall)) name(g1, replace) 

restore

graph combine g1 h1, col(1) xcom

*Model 4 of Table A5
cmp (majorgoalcompliance= thirdpartyrival_cinc costlysanctions thirdrivalcinc_cost  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(majorgoalsanctions = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel si_sanc si_sanc2 si_sanc3), ///
ind(majorgoalsanctions*$cmp_probit $cmp_probit) robust  

*Model 1 of Table A6
cmp (modestgoalcompliance = thirdpartyrival_pd costlysanctions thirdpartyrival_cost_pd  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(modestgoalsanctions = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel mi_sanc mi_sanc2 mi_sanc3), ///
ind(modestgoalsanctions*$cmp_probit $cmp_probit) robust  

*Top panel of Figure A4
preserve

drawnorm b1-b27, n(10000) means(e(b)) cov(e(V)) clear
	  
cap postclose simulation
postfile simulation triv pr_y1 pr_y2 diff diff_l diff_h using "simulation", replace

foreach n of numlist 0(1)8 {
		
	cap drop y1 y2 diff* pr*

		scalar riv = `n'
		scalar pol_riv = 0
		scalar riv_comp = 0
		scalar comp = 0
		scalar inst = 0
		scalar tdem = -0.75
		scalar trddep =  .019
		scalar biriv = 0
		scalar gdppc = 8.071
		scalar tcinc = -6.03
		scalar post = 1
		scalar dur = 5.96
		scalar cons = 1

		generate y1 = b1*riv ///
					+ b2*comp ///
					+ b3*riv_comp ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y1 = normprob(y1)
		sum pr_y1
		local pr_y1 =r(mean)
		

		generate y2 = b1*riv ///
					+ b2*(comp + 1) ///
					+ b3*(riv_comp + `n') ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y2 = normprob(y2)
		sum pr_y2
		local pr_y2 =r(mean)
		
		gen diff = pr_y2 - pr_y1
		sum diff 
		local diff =r(mean)
		
		_pctile diff, p(2.5,97.5)
		local diff_l= r(r1)
		local diff_h= r(r2)  
		
	
post simulation (`n') (`pr_y1') (`pr_y2') (`diff') (`diff_l') (`diff_h') 
	}
postclose simulation

use simulation, clear

gen hist = .
replace hist = 50.8 if triv == 0
replace hist = 23.5 if triv == 1
replace hist = 11.7 if triv == 2
replace hist = 6.3 if triv == 3
replace hist = 3.0 if triv == 4
replace hist = 0.5 if triv == 5
replace hist = 2.1 if triv == 6
replace hist = 1.2 if triv == 7
replace hist = 0.9 if triv == 8

twoway (line diff triv, lpattern(solid) yaxis(1)) (line diff_l triv, lpattern(dash) yaxis(1)) (line diff_h triv, lpattern(dash) yaxis(1)) ///
(bar hist triv, yaxis(2) barw(.2) color(%30) ytitle("Percent", axis(2)) ylabel(0(10)40, axis(2))), ///
yline(0,lpattern(dash)) ylabel(-.8(.2).4) ytitle("Change of pr(Target Compliance)", size(medsmall)) xtitle("Third-Party Rivals", size(medsmall)) ///
legend(off) title("Effect of Costly Sanctions (Modest Policy Goals)", size(medsmall)) name(g1, replace) 

restore

*Model 2 of Talbe A6
cmp (majorgoalcompliance = thirdpartyrival_pd costlysanctions thirdpartyrival_cost_pd  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(majorgoalsanctions = internationalrival_sel_pd targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel si_sanc si_sanc2 si_sanc3), ///
ind(majorgoalsanctions*$cmp_probit $cmp_probit) robust  

*Model 3 of Talbe A6
cmp (modestgoalcompliance = thirdpartyrival_sr costlysanctions thirdpartyrival_cost_sr  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(modestgoalsanctions = internationalrival_sel_sr targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel mi_sanc mi_sanc2 mi_sanc3), ///
ind(modestgoalsanctions*$cmp_probit $cmp_probit) robust  

*Bottom Panel of Figure A4
preserve

drawnorm b1-b27, n(10000) means(e(b)) cov(e(V)) clear
	  
cap postclose simulation
postfile simulation triv pr_y1 pr_y2 diff diff_l diff_h using "simulation", replace

foreach n of numlist 0(1)6 {
		
	cap drop y1 y2 diff* pr*

		scalar riv = `n'
		scalar pol_riv = 0
		scalar riv_comp = 0
		scalar comp = 0
		scalar inst = 0
		scalar tdem = -1.03
		scalar trddep =  .017
		scalar biriv = 0
		scalar gdppc = 8.1
		scalar tcinc = -5.99
		scalar post = 1
		scalar dur = 6.25
		scalar cons = 1

		generate y1 = b1*riv ///
					+ b2*comp ///
					+ b3*riv_comp ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y1 = normprob(y1)
		sum pr_y1
		local pr_y1 =r(mean)
		

		generate y2 = b1*riv ///
					+ b2*(comp + 1) ///
					+ b3*(riv_comp + `n') ///
					+ b4*inst ///
					+ b5*biriv ///
					+ b6*tdem ///
					+ b7*gdppc ///
					+ b8*tcinc  ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur ///
					+ b12*cons 
						
		gen pr_y2 = normprob(y2)
		sum pr_y2
		local pr_y2 =r(mean)
		
		gen diff = pr_y2 - pr_y1
		sum diff 
		local diff =r(mean)
		
		_pctile diff, p(2.5,97.5)
		local diff_l= r(r1)
		local diff_h= r(r2)  
		
	
post simulation (`n') (`pr_y1') (`pr_y2') (`diff') (`diff_l') (`diff_h') 
	}
postclose simulation

use simulation, clear

gen hist = .
replace hist = 55 if triv == 0
replace hist = 19.1 if triv == 1
replace hist = 13 if triv == 2
replace hist = 4.1 if triv == 3
replace hist = 7.9 if triv == 4
replace hist = .8 if triv == 6

twoway (line diff triv, lpattern(solid) yaxis(1)) (line diff_l triv, lpattern(dash) yaxis(1)) (line diff_h triv, lpattern(dash) yaxis(1)) ///
(bar hist triv, yaxis(2) barw(.2) color(%30) ytitle("Percent", axis(2)) ylabel(0(10)40, axis(2))), ///
yline(0,lpattern(dash)) ylabel(-.8(.2).4) ytitle("Change of pr(Target Compliance)", size(medsmall)) xtitle("Third-Party Rivals", size(medsmall)) ///
legend(off) title("Effect of Costly Sanctions (Modest Policy Goals)", size(medsmall)) name(g1, replace) 

restore

*Model 4 of Talbe A6
cmp (majorgoalcompliance = thirdpartyrival_sr costlysanctions thirdpartyrival_cost_sr  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(majorgoalsanctions = internationalrival_sel_sr targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel si_sanc si_sanc2 si_sanc3), ///
ind(majorgoalsanctions*$cmp_probit $cmp_probit) robust  

*Model1 of Table A7
cmp (targetcompliance = thirdpartyrival costlysanctions majorpolicygoal ///
thirdpartyrival_cost  thirdpartyrival_goal thirdpartyrival_cost_goal  cost_goal ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(sanction = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel t_sanc-t_sanc3), ///
ind(sanction*$cmp_probit $cmp_probit) robust  

*Figure A5
preserve

drawnorm b1-b31, n(10000) means(e(b)) cov(e(V)) clear
	  
cap postclose simulation
postfile simulation triv pr_npnc pr_npc diff_npc diff_npcl diff_npch diff_npcl90 diff_npch90 ///
pr_pnc pr_pc diff_pc diff_pcl diff_pch diff_pcl90 diff_pch90 using "simulation", replace

foreach n of numlist 0(1)10 {
		
	cap drop npnc npc pnc pc diff* pr*

		scalar riv = `n'
		scalar pol_riv = 0
		scalar riv_comp = 0
		scalar pol_riv_comp  = 0
		scalar issue = 0
		scalar inst = 0
		scalar tdem = -1
		scalar trddep =  .017
		scalar biriv = 0
		scalar gdppc = 7.84
		scalar scinc = 0.063
		scalar tcinc = -6.18
		scalar post = 1
		scalar comp = 0
		scalar polcomp = 0
		scalar dur = 6.4
		scalar cons = 1

		generate npnc = b1*riv ///
					+ b2*comp ///
					+ b3*issue ///
					+ b4*riv_comp ///
					+ b5*pol_riv  ///
					+ b6* pol_riv_comp  ///
					+ b7*polcomp ///
					+ b8*inst ///
					+ b9*biriv ///
					+ b10*tdem ///
					+ b11*gdppc ///
					+ b12*tcinc ///
					+ b13*trddep  ///
					+ b14*post ///
					+ b15*dur ///
					+ b16*cons 
						
		gen pr_npnc = normprob(npnc)
		sum pr_npnc
		local pr_npnc =r(mean)
		
*******************************		
		generate npc = b1*riv ///
					+ b2*1 ///
					+ b3*issue ///
					+ b4*(riv_comp + `n') ///
					+ b5*pol_riv  ///
					+ b6* pol_riv_comp  ///
					+ b7*polcomp ///
					+ b8*inst ///
					+ b9*biriv ///
					+ b10*tdem ///
					+ b11*gdppc ///
					+ b12*tcinc ///
					+ b13*trddep  ///
					+ b14*post ///
					+ b15*dur ///
					+ b16*cons 
						
		gen pr_npc = normprob(npc)
		sum pr_npc
		local pr_npc =r(mean)
		
		gen diff_npc = pr_npc - pr_npnc
		sum diff_npc 
		local diff_npc =r(mean)
		
		_pctile diff_npc, p(2.5,97.5)
		local diff_npcl= r(r1)
		local diff_npch= r(r2)  
		
		_pctile diff_npc, p(5,95)
		local diff_npcl90= r(r1)
		local diff_npch90= r(r2)  
		
		
*******************************		
		generate pnc = b1*riv ///
					+ b2*comp ///
					+ b3*1 ///
					+ b4*riv_comp ///
					+ b5*(pol_riv + `n') ///
					+ b6* pol_riv_comp  ///
					+ b7*polcomp ///
					+ b8*inst ///
					+ b9*biriv ///
					+ b10*tdem ///
					+ b11*gdppc ///
					+ b12*tcinc ///
					+ b13*trddep  ///
					+ b14*post ///
					+ b15*dur ///
					+ b16*cons 
						
		gen pr_pnc = normprob(pnc)
		sum pr_pnc
		local pr_pnc =r(mean)
				
*******************************
		
		generate pc = b1*riv ///
					+ b2*1 ///
					+ b3*1 ///
					+ b4*(riv_comp +`n') ///
					+ b5*(pol_riv +`n') ///
					+ b6*(pol_riv_comp +`n') ///
					+ b7*1 ///
					+ b8*inst ///
					+ b9*biriv ///
					+ b10*tdem ///
					+ b11*gdppc ///
					+ b12*tcinc ///
					+ b13*trddep  ///
					+ b14*post ///
					+ b15*dur ///
					+ b16*cons 	
		
		gen pr_pc = normprob(pc)
		sum pr_pc
		local pr_pc =r(mean)
				
		gen diff_pc = pr_pc - pr_pnc
		sum diff_pc 
		local diff_pc =r(mean)
		
		_pctile diff_pc, p(2.5,97.5)
		local diff_pcl= r(r1)
		local diff_pch= r(r2)  
		
		_pctile diff_pc, p(5,95)
		local diff_pcl90= r(r1)
		local diff_pch90= r(r2)  

		
post simulation (`n') (`pr_npnc') (`pr_npc') (`diff_npc') (`diff_npcl') (`diff_npch') (`diff_npcl90') (`diff_npch90') ///
 (`pr_pnc')  (`pr_pc') (`diff_pc') (`diff_pcl') (`diff_pch') (`diff_pcl90') (`diff_pch90') ///
 
 }
postclose simulation

use simulation, clear

gen hist = .
replace hist = 39.1 if triv == 0
replace hist = 23.2 if triv == 1
replace hist = 11.8 if triv == 2
replace hist = 9 if triv == 3
replace hist = 3.6 if triv == 4
replace hist = 6.6 if triv == 5
replace hist = 2.5 if triv == 6
replace hist = 1.6 if triv == 7
replace hist = 1.8 if triv == 8
replace hist = 0.8 if triv == 9
replace hist = 0.2 if triv == 10

twoway (line diff_npc triv, lpattern(solid) yaxis(1)) (line diff_npcl triv, lpattern(dash) yaxis(1)) (line diff_npch triv, lpattern(dash) yaxis(1)) ///
/*(rarea diff_npcl90 diff_npch90 triv, color(%30) yaxis(1))*/ ///
(bar hist triv, yaxis(2) barw(.2) color(%30) ytitle("Percent", axis(2)) ylabel(0(10)40, axis(2))), ///
yline(0,lpattern(dash)) ylabel(-.8(.2).4) ytitle("Change of pr(Target Compliance)", size(medsmall)) xtitle("Third-Party Rivals", size(medsmall)) ///
legend(off) title("Effect of Costly Sanctions (Modest Policy Goals)", size(medsmall)) name(g1, replace) 

twoway (line diff_pc triv, lpattern(solid) yaxis(1)) (line diff_pcl triv, lpattern(dash) yaxis(1)) (line diff_pch triv, lpattern(dash) yaxis(1)) ///
/*(rarea diff_pcl90 diff_pch90 triv, color(%30) yaxis(1))*/ ///
(bar hist triv, yaxis(2) barw(.2) color(%30) ytitle("Percent", axis(2)) ylabel(0(10)40, axis(2))), ///
yline(0,lpattern(dash)) ylabel(-.8(.2).4) ytitle("Change of pr(Target Compliance)", size(medsmall)) xtitle("Third-Party Rivals", size(medsmall)) ///
legend(off) title("Effect of Costly Sanctions (Major Policy Goals)", size(medsmall)) name(g3, replace) 

restore

***********************************************
*Figure A6
preserve 
qui cmp (modestgoalcompliance = thirdpartyrival costlysanctions thirdpartyrival_cost  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration) ///
(modestgoalsanctions = internationalrival_sel targetpolity_sel logtargetgdppc_sel logtargetcinc_sel tradeopenness_sel ///
coup_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel mi_sanc mi_sanc2 mi_sanc3), ///
ind(modestgoalsanctions*$cmp_probit $cmp_probit) robust  

keep if e(sample)

interflex modestgoalcompliance costlysanctions thirdpartyrival  ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration, type(kernel) vce(robust) bw(8.9125)

restore


*************************************************************************
use TIES.dta, clear

*Model 1 of Table A3
cmp (targetcompliance = thirdpartyrival costlysanctions ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration threat) ///
(imposition = thirdpartyrival_sel senderpolity_sel targetpolity_sel sender_target_rival_sel logtargetgdppc_sel ///
relativecinc_sel tradedependence_sel tradeopenness_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel threatdur*), ///
ind(imposition*$cmp_probit $cmp_probit) robust  

*Model 2 of Table A3
cmp (targetcompliance = thirdpartyrival costlysanctions thirdpartyrival_cost ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration threat) ///
(imposition = thirdpartyrival_sel senderpolity_sel targetpolity_sel sender_target_rival_sel logtargetgdppc_sel ///
relativecinc_sel tradedependence_sel tradeopenness_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel threatdur*), ///
ind(imposition*$cmp_probit $cmp_probit) robust  

*Model 3 of Table A3
preserve

keep if majorpolicygoal == 0

cmp (targetcompliance = thirdpartyrival costlysanctions thirdpartyrival_cost ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration threat) ///
(imposition = thirdpartyrival_sel senderpolity_sel targetpolity_sel sender_target_rival_sel logtargetgdppc_sel ///
relativecinc_sel tradedependence_sel tradeopenness_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel threatdur*), ///
ind(imposition*$cmp_probit $cmp_probit) robust  

*Figure A1
drawnorm b1-b30, n(10000) means(e(b)) cov(e(V)) clear
	  
cap postclose simulation
postfile simulation triv pr0 pr1 diff diff_h diff_l diff_h90 diff_l90 using "simulation", replace

foreach n of numlist 0(1)8 {
		
	cap drop coeff* pr* diff* 

		scalar riv = `n'
		scalar comp_riv = 0
		scalar comp = 0
		scalar inst = 0
		
		scalar tdem = 5.71
		scalar trddep = .04
		scalar biriv = 0
		scalar gdppc = 9.09
		scalar tcinc = -4.9
		scalar post = 1
		scalar threat = 1
		scalar dur = 3.32
		scalar cons = 1

		generate coeff0 = b1*riv ///
					+ b2*comp ///
					+ b3*comp_riv ///
					+ b4*inst ///
					+ b5*biriv  ///
					+ b6*tdem  ///
					+ b7*gdppc ///
					+ b8*tcinc ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur  ///
					+ b12*threat ///
					+ b13*cons
						
		gen pr0 = normprob(coeff0)
		sum pr0
		local pr0 =r(mean)
				
*******************************		
		generate coeff1 = b1*riv ///
					+ b2*1 ///
					+ b3*(comp_riv + `n') ///
					+ b4*inst ///
					+ b5*biriv  ///
					+ b6*tdem  ///
					+ b7*gdppc ///
					+ b8*tcinc ///
					+ b9*trddep ///
					+ b10*post ///
					+ b11*dur  ///
					+ b12*threat ///
					+ b13*cons
						
		gen pr1 = normprob(coeff1)
		sum pr1
		local pr1 =r(mean)
		
		gen diff = pr1 - pr0
		sum diff
		local diff =r(mean)
		
		_pctile diff , p(2.5,97.5)
		local diff_l= r(r1)
		local diff_h= r(r2)  
		
		_pctile diff , p(5,95)
		local diff_l90= r(r1)
		local diff_h90= r(r2)  
		
				
post simulation (`n') (`pr0') (`pr1') (`diff') (`diff_l') (`diff_h') (`diff_l90') (`diff_h90')
	}
postclose simulation

use simulation, clear

gen hist = .
replace hist = 43.4 if triv == 0
replace hist = 20.1 if triv == 1
replace hist = 11.4 if triv == 2
replace hist = 11 if triv == 3
replace hist = 0.5 if triv == 4
replace hist = 2.7 if triv == 5
replace hist = 3.2 if triv == 6
replace hist = 6.4 if triv == 7
replace hist = 1.4 if triv == 8


twoway (line diff triv, lpattern(solid) yaxis(1)) (line diff_l triv, lpattern(dash) yaxis(1)) (line diff_h triv, lpattern(dash) yaxis(1)) ///
/*(rarea diff_l90 diff_h90 triv, color(%30) yaxis(1))*/ ///
(bar hist triv, yaxis(2) barw(.2) color(%30) ytitle("Percent", axis(2)) ylabel(0(10)40, axis(2))), ///
yline(0,lpattern(dash)) ytitle("Change of pr(Target Compliance)", size(small)) xtitle("Third-Party Rivals") ///
legend(off) title("Effect of Costly Sanctions (Modest Policy Goals)", size(small)) name(g1, replace) 

restore 

*Model 4 of Table A3
preserve

keep if majorpolicygoal == 1

cmp (targetcompliance = thirdpartyrival costlysanctions thirdpartyrival_cost ///
institution sender_target_rival targetpolity logtargetgdppc logtargetcinc tradedependence postcoldwar duration threat) ///
(imposition = thirdpartyrival_sel senderpolity_sel targetpolity_sel sender_target_rival_sel logtargetgdppc_sel ///
relativecinc_sel tradedependence_sel tradeopenness_sel humanrights_sel mid_sel civilwar_sel postcoldwar_sel threatdur*), ///
ind(imposition*$cmp_probit $cmp_probit) robust  

restore 
